package com.wj.ballcat.demo.model.entity;

import com.tangzc.mpe.actable.annotation.ColumnComment;
import com.tangzc.mpe.actable.annotation.Table;
import com.tangzc.mpe.datasource.annotation.Condition;
import com.tangzc.mpe.datasource.annotation.DataSource;
import lombok.Data;

@Data
@Table(comment = "评论")
public class Comment {
	@ColumnComment("主键")
	private String id;

	@ColumnComment("评论内容")
	private String content;

	@ColumnComment("评论人id")
	private String userId;

	// source指定了数据来源的Entity，同样可以使用sourceName来指定全路径的方式，field指定了映射哪个字段
	// conditions中隐含了一个joinField字段，该字段默认是“id”，即@Condition(selfField = "userId", joinField = "id")等同于示例中的写法
	@DataSource(
			source = DemoUser.class,
			field = "username",
			conditions = @Condition(selfField = "userId"),
			updateCondition = "1=1"
	)
	@ColumnComment("评论人名称")
	private String userName;

	// 如上，同理

	@DataSource(
			source = DemoUser.class,
			field = "icon",
			conditions = @Condition(selfField = "userId"),
			updateCondition = "1=1")
	@ColumnComment("评论人头像")
	private String userIcon;
}
